//
//  AppStorageBootcamp.swift
//  FCSwiftUI
//
//  Created by 冯宣超 on 2023/3/12.
//

import SwiftUI

struct AppStorageBootcamp: View {
    @AppStorage("kUserDefaultsKey_UserName") var currentUserName: String?
    
    var body: some View {
        VStack(spacing: 20.0) {
            if let userName = currentUserName {
                Text("Current User Name:")
                Text(userName)
            } else {
                Text("Add Name Here")
            }
            
            Button("SAVE") {
                currentUserName = "FC"
            }
        }
    }
}

struct AppStorageBootcamp_Previews: PreviewProvider {
    static var previews: some View {
        AppStorageBootcamp()
    }
}
